package com.krediti.session;

import java.util.Arrays;
import java.util.List;

import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;

import com.krediti.entity.Korisnik;

@Name("korisnikList")
public class KorisnikList extends EntityQuery<Korisnik> {

	/**
	 * Generated serial version.
	 */
	private static final long serialVersionUID = 4858086426482889677L;

	private static final String[] RESTRICTIONS = {
			"lower(korisnik.adresa) like concat(lower(#{korisnikList.korisnik.adresa}),'%')",
			"lower(korisnik.drzava) like concat(lower(#{korisnikList.korisnik.drzava}),'%')",
			"lower(korisnik.ime) like concat(lower(#{korisnikList.korisnik.ime}),'%')",
			"lower(korisnik.mesto) like concat(lower(#{korisnikList.korisnik.mesto}),'%')",
			"lower(korisnik.password) like concat(lower(#{korisnikList.korisnik.password}),'%')",
			"lower(korisnik.prezime) like concat(lower(#{korisnikList.korisnik.prezime}),'%')",
			"lower(korisnik.username) like concat(lower(#{korisnikList.korisnik.username}),'%')", };

	private Korisnik korisnik = new Korisnik();

	@Override
	public String getEjbql() {
		return "select korisnik from Korisnik korisnik";
	}

	@Override
	public Integer getMaxResults() {
		return 25;
	}

	public Korisnik getKorisnik() {
		return korisnik;
	}

	@Override
	public List<String> getRestrictions() {
		return Arrays.asList(RESTRICTIONS);
	}

}
